/*
 * @Author: chengjiang
 * @Date: 2024-06-08 16:43:15
 * @Description: 
 */
import request from '@/utils/request'
import axios from 'axios'
export interface GoldInfo {
  //   variety: string /*品种*/
  //   latestpri: string /*最新价*/
  //   openpri: string /*开盘价*/
  //   maxpri: string /*最高价*/
  //   minpri: string /*最低价*/
  //   limit: string /*涨跌幅*/
  //   yespri: string /*昨收价*/
  //   totalvol: string /*总成交量*/
  //   time: string /*更新时间*/
  Buy: number
  C: String
  H: number
  L: number
  Sell: number
  name: String
  MaxMni: { H: number; L: number }
}
export interface Result {
    items: Map<string, GoldInfo>,
    pubtime: string,
    result: string,
}

// 这个是点金贵的接口：
export function getGoldInfo<Result>(params: Object) {
  return request<Result>({
    // url: '/juhe_api/finance/gold/shgold',
    // url: '/djkx9999_api/get_price',
    url: '/djkx9999_api/web/v1/prices/list',
    method: 'get',
    params
  })
}
export interface Custgold {
  date: string,
  priceData: Map<string, string>,
  status: string,
}

export function getCustGoldInfo<Custgold>(params: Object) {
  return request<Custgold>({
    // url: '/juhe_api/finance/gold/shgold',
    // url: '/djkx9999_api/get_price',
    url: '/custgold_api/web/v1/shuibei-price',
    method: 'get',
    params
  })
}

export interface Req {
  type?: number,
  priceType: number,
}

// 后端金价配置。
export interface GoldPrice {
  id: number,
  priceType: number, // 0: 看价盘，1: customer临售盘
  currencyCode: string, // 币种英文代码
  currencyName: string, // 币种中文名称
  recyclePrice: number, // 回收价
  sellPrice: number, // 销售价
}

export function ListGoldSetting(data: Req) {
  return request<Array<GoldPrice>>({
    url: '/back/open-api/basic/setting/gold/config/list/1',
    method: 'post',
    data,
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}

// 开闭盘：
export interface OpenClose {
  id: number,
  status: number, // 0: open, 1: close
  effectHour: number,
  updateTime?: string,
}
export function GetOpenClose() {
  return request<OpenClose>({
    url: '/back/open-api/basic/setting/quotation/time/get/1',
    method: 'get',
    meta: {
      responseAll: true // 返回所有的信息，包括状态码和message和data
    }
  } as any)
}